<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //查找字符串”abcoefoxyozzopp”中o出现的位置以及次数。
        let arr=["a","b","c","o","e","f","o","x","y","o","z","z","o","p","p"];
        let cs = 0;
        let wz=arr.indexOf("o");
        while(wz != -1){
            console.log("o出现的位置在："+wz);
            cs++;
            wz= arr.indexOf("o",wz+1)
        }
        console.log("次数为："+cs+"次");
    </script>
</body>
</html>